HAL NOR IO Operation functions migration

This section provides information about the HAL NOR function migration.

Note

In HAL1, the APIs take an absolute address for the memory location, while in HAL2, the APIs use an offset from a base address.

HAL NOR reads flash ID.

HAL1

HAL2

HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor,
                   NOR_IDTypeDef *pNOR_ID);
/* For Command Set 1 */
HAL_NOR_CFI_0001_ReadDeviceIdentifier(hal_nor_handle_t *hnor,
                       hal_nor_cfi_0001_device_id_t *p_nor_id);
/* For Command Set 2 */
HAL_NOR_CFI_0002_ReadDeviceIdentifier(hal_nor_handle_t *hnor,
                       hal_nor_cfi_0002_device_id_t *p_nor_id);
/* For Command Set 3 */
HAL_NOR_CFI_0003_ReadDeviceIdentifier(hal_nor_handle_t *hnor,
                       hal_nor_cfi_0003_device_id_t *p_nor_id);

Related types: HAL NOR ID type definition


HAL NOR return flash to read mode.

HAL1

HAL2

HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor);
/* For Command set 1 */
HAL_NOR_CFI_0001_Reset(hal_nor_handle_t *hnor);
/* For Command set 2 */
HAL_NOR_CFI_0002_Reset(hal_nor_handle_t *hnor);
/* For Command set 3 */
HAL_NOR_CFI_0003_Reset(hal_nor_handle_t *hnor);

Related use case: Use case: program and read operations


HAL NOR read data

HAL1

HAL2

The HAL_NOR_Read() reads one 16-bit ( uint16_t) variable.

The read functions read data by specifying size_byte parameter equal to two to read one 16-bit ( uint16_t) variable.

HAL_NOR_Read(&hnor, device_address, data_read);
/* For Command Set 1 */
HAL_NOR_CFI_0001_ReadArray(&hnor, device_address, data_read, 2);
/* For Command Set 2 */
HAL_NOR_CFI_0002_Read(&hnor, device_address, data_read, 2);
/* For Command Set 3 */
HAL_NOR_CFI_0003_ReadArray(&hnor, device_address, data_read, 2);

HAL NOR program data

HAL1

HAL2

HAL_NOR_Program(&hnor,
                 (uint32_t)0x60000000 + offset_byte,
                 &pData);
/* For Command Set 1 */
HAL_NOR_CFI_0001_Program(&hnor,
                         offset_byte,
                         data,
                         1000);
/* For Command Set 2 */
HAL_NOR_CFI_0002_Program(&hnor,
                         offset_byte,
                         data,
                         1000);
/* For Command Set 3 */
HAL_NOR_CFI_0003_Program(&hnor,
                         offset_byte,
                         data,
                         1000);

Related use case: Use case: program and read operations


HAL NOR read a buffer

HAL1

HAL2

HAL_NOR_ReadBuffer(&hnor,
                   (uint32_t)0x60000000 + offset_byte,
                   &pData,
                   uwBufferSize);
/* For Command Set 1 */
HAL_NOR_CFI_0001_ReadArray(&hnor,
                           offset_byte,
                           p_data,
                           size_byte);
/* For Command Set 2 */
HAL_NOR_CFI_0002_Read(&hnor,
                       offset_byte,
                       p_data,
                       size_byte);
/* For Command Set 3 */
HAL_NOR_CFI_0003_ReadArray(&hnor,
                           offset_byte,
                           p_data,
                           size_byte);

Related use case: Use case: program and read operations


HAL NOR program buffer

HAL1

HAL2

HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor,
                       (uint32_t)0x60000000 + offset_byte,
                       &pData,
                       uwBufferSize);
/* For Command Set 1 */
HAL_NOR_CFI_0001_BufferedProgram(&hnor,
                                 offset_byte,
                                 p_data,
                                 size_byte,
                                 1000);
/* For Command Set 2 */
HAL_NOR_CFI_0002_BufferedProgram(&hnor,
                                 offset_byte,
                                 p_data,
                                 size_byte,
                                 1000);

HAL NOR erase block

HAL1

HAL2

HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor,
                     uint32_t BlockAddress,
                     uint32_t Address);
/* For Command Set 1 */
HAL_NOR_CFI_0001_BlockErase(hal_nor_handle_t *hnor,
                             uint32_t block_offset_byte,
                             uint32_t timeout_ms);
/* For Command Set 2 */
HAL_NOR_CFI_0002_BlockErase(hal_nor_handle_t *hnor,
                             uint32_t block_offset_byte,
                             uint32_t timeout_ms);
/* For Command Set 3 */
HAL_NOR_CFI_0003_BlockErase(hal_nor_handle_t *hnor,
                             uint32_t block_offset_byte,
                             uint32_t timeout_ms);

Related concepts: Other HAL NOR changes


HAL NOR erase chip

HAL1

HAL2

HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor,
                   uint32_t Address);
HAL_NOR_CFI_0002_ChipErase(hal_nor_handle_t *hnor,
                           uint32_t timeout_ms);

Note

The timeout value is in milliseconds.

In HAL1, the Address is not used internally. It is removed in HAL2.

Related concepts: Other HAL NOR changes


HAL NOR read the Common Flash Interface (CFI) data.

HAL1

HAL2

HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor,
                 NOR_CFITypeDef *pNOR_CFI);
HAL_NOR_CFI_ReadDeviceInfo(hal_nor_handle_t *hnor,
                           hal_nor_cfi_device_info_t *p_device_info);

Related types: HAL NOR common flash interface type definition

Related use case: Use case: read operations of CFI information